package workflow;

import java.util.Date;

public class WorkflowEvent {

	public enum EventType {
		START, END
	}
	
	private int workflowId;
	private String taskName;
	private EventType eventType;
	private Date timestamp = new Date();
	
	public WorkflowEvent(int id, String task, EventType type) {
		this.workflowId = id;
		this.taskName = task;
		this.eventType = type;
	}
	
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Workflow '");
		builder.append(getWorkflowId());
		if (getEventType() == EventType.START) {
			builder.append("' started task '");
		} else {
			builder.append("' finished task '");
		}
		builder.append(getTaskName());
		builder.append("'! Time: ");
		builder.append(getTimestamp());
		return builder.toString();
	}
	
	public int getWorkflowId() {
		return workflowId;
	}
	
	public EventType getEventType() {
		return eventType;
	}
	
	public String getTaskName() {
		return taskName;
	}
	
	public Date getTimestamp() {
		return timestamp;
	}
	
	public void setEventType(EventType eventType) {
		this.eventType = eventType;
	}
	
	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}
	
	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}
	
	public void setWorkflowId(int workflowId) {
		this.workflowId = workflowId;
	}
	
	public static final WorkflowEvent createEvent(int id, String task, EventType type) {
		return new WorkflowEvent(id, task, type);
	}
	
}
